<template>
  <div class="navigator">
    <el-menu 
      :collapse="collapse"
      background-color="#212434"
      text-color="#ffffff"
      active-text-color="#0c66ff"
      :collapse-transition="false"
      :unique-opened="false"
      @select="handleClick"
    >
      <el-menu-item 
        v-for="(menu, index) in injectData" 
        :key="index" 
        :index="`${index}`"
        :menu="menu"
      >
        <i :class="`el-icon-${menu.icon}`"></i>
        <span slot="title">{{ menu.title }}</span>
      </el-menu-item>
  </el-menu>
  </div>
</template>

<style lang="scss" scoped>
@import './navigator.scss';
</style>

<script>
export default {
  name: 'sl-navigator',
  props: {
    injectData: {
      type: Array,
      default: () => []
    },
    collapse: {
      type: Boolean,
      default: true
    }
  },
  methods: {
    handleClick (key, keyPath, menu) {
      this.$emit('click', menu.$attrs.menu);
    }
  }
}
</script>